package com.example.demo.controller;

import com.example.demo.base.JPushBase;
import com.example.demo.base.MessageBase;
import com.example.demo.service.TextService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;


@RestController
public class TextController {

    // 文档
    // https://docs.jiguang.cn//jpush/server/push/rest_api_v3_push/

    @Autowired
    TextService textService;

    @GetMapping("/message")
    public String sendMessage() {
        //拼接参数
        JPushBase jPushBase = new JPushBase();
        jPushBase.setAudience("all");
        jPushBase.setPlatform("all");
        MessageBase messageBase = new MessageBase();
        messageBase.setContent_type("text");
        messageBase.setMsg_content("Hi,JPush");
        messageBase.setTitle("msg");
        HashMap<String, String> hashMap = new HashMap<>();

        hashMap.put("aaaa", "bbb");
        hashMap.put("bbbb", "cccc");
        hashMap.put("dddd", "dddd");
        hashMap.put("pppp", "qqqqq");

        messageBase.setExtras(hashMap);
        jPushBase.setMessage(messageBase);
        return textService.setMessage(jPushBase);
    }

    @GetMapping("/cid")
    public String getCidList() {
        return textService.getCidList(1);
    }


}
